package cn.k.service.impl;

import cn.k.domain.ConsumptionItem;
import cn.k.mapper.ConsumptionItemMapper;
import cn.k.qo.QueryObject;
import cn.k.service.IConsumptionItemService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class ConsumptionItemServiceImpl implements IConsumptionItemService {
    @Autowired
    private ConsumptionItemMapper consumptionItemMapper;

    @Override
    @Transactional
    public void insert(ConsumptionItem consumptionItem) {
         consumptionItemMapper.insert(consumptionItem);
    }

    @Override
    public void delete(Long id) {
        consumptionItemMapper.deleteByPrimaryKey(id);

    }

    @Override
    @Transactional
    public void update(ConsumptionItem consumptionItem) {
        consumptionItemMapper.updateByPrimaryKey(consumptionItem);

    }

    @Override
    public ConsumptionItem get(Long id) {
        ConsumptionItem consumptionItem = consumptionItemMapper.selectByPrimaryKey(id);
        return consumptionItem;
    }

    @Override
    public List<ConsumptionItem> selectAll() {
        List<ConsumptionItem> consumptionItems = consumptionItemMapper.selectAll();
        return consumptionItems;
    }


    @Override
    public List<ConsumptionItem> selectForList(QueryObject qo) {
        List<ConsumptionItem> consumptionItems = consumptionItemMapper.selectForList(qo);
        return consumptionItems;
    }

    @Override
    public List<ConsumptionItem> queryByCno(String cno) {
        return consumptionItemMapper.selectByCno(cno);
    }


}
